Active Directory: Determining DN or OU from log in credentials [closed]

Posted by Christopher Broome on Server Fault See other posts from Server Fault or by Christopher Broome
Published on 2012-10-26T14:35:25Z Indexed on 2012/10/27 11:05 UTC
Read the original article Hit count: 234

Filed under:
|
|

I'm updating a PHP login process to leverage active directory on a Windows server. The logging in process seems pretty straight forward via a "ldap_bind", but I also want to pull some profile information from the AD server (first name, last name, etc...) which seems to require a robust distinguished name (DN).

When on the windows server I can grab this via 'dsquery user' on the command prompt, but is there a way to get the same value from just the user's login credentials in PHP? I want to avoid getting a list of hundreds of DNs when on-boarding clients and associating each with one of our users, so any means to programmatically determine this would be preferential.

Otherwise, I'll know the domain and host for the request so I can at least set the DC portions of the DN, but the organizational units (OU) seem to be pretty important for querying data. If I can find some of the root level OU values associated with the user I can do a ldap_search and crawl.

I browsed through the existing questions and found some similar but nothing that really addressed this, so my apologies if the obvious answer is out there.

Thanks for the help.

© Server Fault or respective owner

Related posts about php

Related posts about active-directory